<?php

/**
 * 清洗老报名数据到新库中
 * 跑一次
 * @author lyl
 **/


ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';

use Doraemon\service\Article as sArticle;
use Doraemon\model\DesignerCompetitionProduct as  mDesignerCompetitionProduct;
use Biz\model\designerAward\Sign as mSign;
use Doraemon\service\Activity\DesignerCompetitionService;
use Doraemon\tools\IdParse;

$item = [
    10 => '营造家奖小户型',
    11 => '营造家奖中户型',
    12 => '营造家奖大户型',
    20 => '最佳卫浴设计',
    21 => '最佳厨房设计',
    22 => '最佳客厅设计',
    23 => '最佳儿童房设计',
    24 => '最佳收纳设计',
    25 => '最佳色彩搭配',
    30 => '西门子家电专项',
];

//2017年案例是否参赛了和获奖了
//2017年的案例是否获奖了
$award_2017 = DesignerCompetitionService::SYS_REWARD_LIST;
//2017年参赛案例
$history_2017 = [
    '0000d1i010000974' => '户型改造',
    '0000cy1010000lmk' => '户型改造',
    '0000bap010001e09' => '户型改造',
    '000097j01000aiaf' => '户型改造',
    '0000aki01000hum4' => '户型改造',
    '0000bi801000hiao' => '户型改造',
    '000045y01000c3gr' => '户型改造',
    '000092p01000nud6' => '户型改造',
    '000061z01000czwn' => '户型改造',
    '0000dbn0100012ah' => '户型改造',
    '0000cyt0100086dp' => '户型改造',
    '0000byq010000j19' => '户型改造',
    '00004zg01000cl36' => '户型改造',
    '0000cyg01000oin6' => '户型改造',
    '0000cww01000vnwc' => '户型改造',
    '00004zq010005dez' => '户型改造',
    '000071o010007ezc' => '户型改造',
    '00009n801000tvjq' => '户型改造',
    '000090t010005913' => '户型改造',
    '0000dca0100057ic' => '户型改造',
    '0000d870100015at' => '户型改造',
    '0000agf01000ny22' => '户型改造',
    '0000bb401000k7fk' => '户型改造',
    '0000b1801000a4t9' => '户型改造',
    '00008k3010009wss' => '户型改造',
    '0000dcc01000snbv' => '户型改造',
    '00009om01000dk6u' => '户型改造',
    '00003qu010007sxg' => '户型改造',
    '0000c85010011en3' => '户型改造',
    '0000dd2010001mcq' => '户型改造',
    '0000cx201000nse8' => '户型改造',
    '00003f4010001zun' => '户型改造',
    '0000avd01000dt4t' => '户型改造',
    '000003101000098j' => '户型改造',
    '0000bqk010005q8j' => '户型改造',
    '0000czr010008yqp' => '户型改造',
    '00009f701000148u' => '户型改造',
    '00004ys01000d3c7' => '户型改造',
    '0000d7q010008pan' => '户型改造',
    '00004y001000d5oz' => '户型改造',
    '000092n010008jw2' => '户型改造',
    '000092k010001yxq' => '户型改造',
    '00009cz01000davp' => '户型改造',
    '0000dd5010004sz5' => '户型改造',
    '0000cxv01000nmbf' => '户型改造',
    '0000a8j01000snbv' => '小户型',
    '0000arp01000att2' => '小户型',
    '0000c6z010005mfc' => '小户型',
    '00004f801000c5no' => '小户型',
    '00009oo010001m8o' => '小户型',
    '0000cxw0100109lq' => '小户型',
    '0000bya01000bhb7' => '小户型',
    '00002fw010001yxq' => '小户型',
    '00005ga01000dx8x' => '小户型',
    '000046z010000lmk' => '小户型',
    '00009bk01000nmbf' => '小户型',
    '0000a9m0100057ic' => '小户型',
    '00005nu01000ac88' => '小户型',
    '0000dah010005dez' => '小户型',
    '0000d6501000a9n2' => '小户型',
    '00009gt01000aiaf' => '小户型',
    '0000czm010007sxg' => '小户型',
    '000058f010000g0c' => '小户型',
    '00006j201000csl0' => '小户型',
    '000008s01000098j' => '小户型',
    '00004vx01000cifu' => '小户型',
    '00008lg01000m903' => '小户型',
    '0000ceb01000nse8' => '小户型',
    '00004ep010004sz5' => '小户型',
    '00003ky010000ear' => '软装搭配',
    '00005s401000gbp0' => '软装搭配',
    '0000dfk01000kqio' => '软装搭配',
    '0000bvp01000att2' => '软装搭配',
    '0000dei010000pt7' => '软装搭配',
    '00008j9010001cyq' => '软装搭配',
    '0000d59010003rh3' => '软装搭配',
    '00007rm01000d1ap' => '软装搭配',
    '0000bby010005zxm' => '软装搭配',
    '0000c0t01000z65l' => '软装搭配',
    '000051h01000f20t' => '软装搭配',
    '00007rf010009wss' => '软装搭配',
    '0000cxx010005913' => '软装搭配',
    '0000at9010006rkf' => '软装搭配',
    '00003ce010008n8g' => '软装搭配',
    '00003sk0100009f7' => '软装搭配',
    '0000d63010001pha' => '软装搭配',
    '0000d6p01000cvf0' => '软装搭配',
    '0000ait01000a6dm' => '软装搭配',
    '0000c1k010006jwn' => '软装搭配',
    '0000b5u01000a4t9' => '软装搭配',
    '0000b6201000vnwc' => '软装搭配',
    '00008ub010008yqp' => '软装搭配',
    '00007ns01000csl0' => '软装搭配',
    '00009p501000lxv0' => '软装搭配',
    '000094r01000rkbk' => '软装搭配',
    '0000bbk01000205p' => '软装搭配',
    '0000agz01000ld71' => '软装搭配',
    '0000afl010001dcn' => '软装搭配',
    '000055o01000ewdd' => '软装搭配',
    '00005qc01000gp94' => '软装搭配',
    '00007q001000obe1' => '软装搭配',
    '0000b5001000d5oz' => '软装搭配',
    '00002uk010005913' => '软装搭配',
    '00006xp010007qd4' => '软装搭配',
    '00005hi01000c3gr' => '软装搭配',
    '00006ye010008875' => '软装搭配',
    '0000bba01000k7fk' => '软装搭配',
    '0000cdp01000dk3b' => '软装搭配',
    '00002r8010001gg6' => '软装搭配',
    '00006z8010000vf4' => '软装搭配',
    '0000dc901000i7lp' => '软装搭配',
    '00008xw01000nmbf' => '软装搭配',
    '0000dcy01000prjl' => '软装搭配',
    '0000aic01000kqio' => '色彩搭配',
    '00002fx010000974' => '色彩搭配',
    '00004fe01000csl0' => '色彩搭配',
    '00004uw01000205p' => '色彩搭配',
    '0000ddw01000itvf' => '色彩搭配',
    '0000d0w010008yqp' => '色彩搭配',
    '0000c0201000a6dm' => '色彩搭配',
    '0000cdl01000zoqy' => '色彩搭配',
    '00004rf01000d5oz' => '色彩搭配',
    '0000cv101000udwe' => '色彩搭配',
    '000093n01000i7lp' => '色彩搭配',
    '00003sk0100009f7' => '色彩搭配',
    '0000akl010001pha' => '色彩搭配',
    '00004l8010008pao' => '色彩搭配',
    '0000dai010008875' => '色彩搭配',
    '000063d01000eh0j' => '色彩搭配',
    '000042t01000af60' => '色彩搭配',
    '00004fa010000g0c' => '色彩搭配',
    '0000ads010000oky' => '色彩搭配',
    '0000auv010003rh3' => '色彩搭配',
    '0000d8i01000n0eo' => '色彩搭配',
    '0000b3n01000c3gr' => '色彩搭配',
    '000094u010008jw2' => '色彩搭配',
    '00005qp01000att2' => '色彩搭配',
    '00004ta01000d1ap' => '色彩搭配',
    '0000945010007zft' => '色彩搭配',
    '00002kn010002ddk' => '色彩搭配',
    '00000z0010001dcn' => '色彩搭配',
    '0000auw01000cvf0' => '色彩搭配',
    '0000csh01000c24i' => '色彩搭配',
    '00009v501000khov' => '色彩搭配',
    '0000aaq010007eys' => '色彩搭配',
    '0000d84010011eh8' => '色彩搭配',
    '0000b8901000k7fk' => '色彩搭配',
    '0000cxg01000dk3b' => '色彩搭配',
    '0000db601000kxl8' => '色彩搭配',
    '0000d9g010001gg6' => '色彩搭配',
    '000072q01000davp' => '色彩搭配',
    '00009sl010000vf4' => '色彩搭配',
    '00008y10100086dp' => '色彩搭配',
    '0000das010001mcq' => '色彩搭配',
    '00007rk010009wss' => '色彩搭配',
    '00004qm010000pt7' => '色彩搭配',
    '00009r4010000lmk' => '收纳设计',
    '000070n010007qd4' => '收纳设计',
    '000068l010009yj9' => '收纳设计',
    '00009it0100014yv' => '收纳设计',
    '0000d0u01000a4t9' => '收纳设计',
    '00005j301000gksv' => '收纳设计',
    '0000d1u01000bmkj' => '收纳设计',
    '0000blx010008pao' => '收纳设计',
    '0000anc010000g0c' => '收纳设计',
    '00003gg010007opu' => '收纳设计',
    '00006t101000ld71' => '收纳设计',
    '0000b2i01000oxn7' => '收纳设计',
    '000090c01000cl36' => '收纳设计',
    '00004gc010001yxq' => '收纳设计',
    '0000b8a01000dx8x' => '收纳设计',
    '00007dg01000205p' => '收纳设计',
    '00009sr0100009f7' => '收纳设计',
    '0000d5801000hiao' => '收纳设计',
    '000089201000nud6' => '收纳设计',
    '0000bn6010003rh3' => '收纳设计',
    '000097e01000p1nr' => '收纳设计',
    '0000cp701000dk3b' => '收纳设计',
    '00006yg01000itvf' => '收纳设计',
];
$sum_2017 = 0;
$error_2017 = [];
foreach($history_2017 as $_7k=>&$_7v){
    //通过案例获取uid IdParse::getUid()
    if($uid = IdParse::getUid($_7k)){
        $data = [
            'uid'=> $uid,
            'aid'=> $_7k,
            'descrip'=> $_7v,
            'add_time'=> '2017-01-01 01:00:00',
        ];
        if(in_array($uid, array_keys($award_2017))){
            $data['is_win'] = 1;
        }
        if(mSign::addData($data)){
            $sum_2017++;
            print_r(mSign::log());echo PHP_EOL;
        }else{
            $error_2017[$_7k] = $data;
        }
        unset($data);

    }else{
        $error_2017[$_7k] = $_7v;
    }
}
echo '<======2017年:'.$sum_2017.'=====>'.PHP_EOL;
if(!empty($error_2017)) {
    print_r(json_encode($error_2017, true));
    Log::debug('设计师奖历史数据清洗', json_encode($error_2017, true));
}

//=============================================================================
//2018年的案例是否获奖了
$award_2018 = DesignerCompetitionService::SYS_2018_REWARD_LIST;
//2018 年的历史获奖数据
$hostory_2018 = mDesignerCompetitionProduct::select('*');
$error = [];
$sum = 0;
if(!empty($hostory_2018)){
    foreach($hostory_2018 as $_k=>&$_v){
        $data = [
            'uid'=> $_v['uid'],
            'aid'=> $_v['aid'],
            'descrip'=> $item[$_v['main_item']],
            'add_time'=> $_v['add_time'],
        ];
        if(in_array($_v['uid'], array_keys($award_2018))){
            $data['is_win'] = 1;
        }
        if(mSign::addData($data)){
            $sum++;
            print_r(mSign::log());echo PHP_EOL;
        }else{
            $error[$_k] = $data;
        }
        unset($data);
    }
}

echo '<======2018年:'.$sum.'=====>';
if(!empty($error)) {
    print_r(json_encode($error, true));
    Log::debug('设计师奖历史数据清洗', json_encode($error, true));
}







